from moderation.models import Modification
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from moderation.utils import accept_modification

def queue(request,
          template_name='promisecheck'):
    mods = Modification.objects.filter(status=0)
    return render_to_response('%s/queue.html' % template_name, {
        'mods': mods,
    }, context_instance=RequestContext(request))

def accept(request,
           id,
           template_name='promisecheck'):
    mod = Modification.objects.get(pk=id)
    accept_modification(mod)
    return HttpResponseRedirect(reverse('moderation.views.queue'))

def reject(request,
           id,
           template_name='promisecheck'):
    Modification.objects.get(id=id).delete()
    return HttpResponseRedirect(reverse('moderation.views.queue'))